#ifndef WIDGET_H
#define WIDGET_H

#include <QMenu>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
#include <QWidget>
#include "cityinfo.h"
#include "weatherofdayinfo.h"
#include "ui_widget.h"
#include "timethread.h"


QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    bool eventFilter(QObject *watched, QEvent *event)override;
    void getDataFromUrl(QNetworkReply *reply);
    void updateUiDisplay();
    void weaListInit();
    void weaImgMapInit();
    void drawTempLineH();
    void drawTempLineL();

private slots:
    void on_closeWindow();
    void on_replyFinished(QNetworkReply *reply);
    void on_part1_pushButton_sButton_clicked();
    void on_part1_lineEdit_sFrame_returnPressed();

private:
    Ui::Widget *ui;

//    QTimer *weaTimer;
    QPoint posOffset;
    enum{
        rightPress, leftPress
    };
    bool mouseStatus;
    QMenu *closeMenu;
    QNetworkAccessManager *manager;
    QString  urlAddr;
    weatherofdayinfo day[7];
    QList<QLabel*> listWeek;
    QList<QLabel*> listDate;
    QList<QLabel*> listWeaImg;
    QList<QLabel*> listWeaType;
    QList<QLabel*> listAirLevel;
    QList<QLabel*> listWinDir;
    QList<QLabel*> listWinSpeed;
    QMap<QString, QString> weaImgMap;
    cityInfo cityMap;
    timeThread *updateThread;

signals:
    void run_Init();

};
#endif // WIDGET_H
